/**
 * useRef
 */

import React, { useState, useRef, useEffect } from 'react'
import { Button } from 'antd'

let prev1, prev2;
function Demo() {
  console.log('RENDER')
  let [num, setNum] = useState(0)
  let box1 = useRef(null)
  let box2 = React.createRef(null)
  if (!prev1) {
    prev1 = box1
    prev2 = box2
  } else {
    console.log(prev1 === box1)
    console.log(prev2 === box2)
  }
  useEffect(() => {
    console.log(box1.current)
    console.log(box2.current)
  }, [])

  return <div>
    <div id='num' ref={box1}>{num}</div>
    <div ref={box2}>mallll</div>
    <Button onClick={() => {
      setNum(num + 1)
    }}>新增</Button>
  </div>
}

export default Demo 